home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Fatted Calf
/
The Fatted Calf.iso
/
Applications
/
Graphics
/
Pyramid
/
Source
/
TransformController.m
< prev
Wrap
Text File
|
1993-09-15
|
2KB
|
96 lines
/* TransformController.m - Determine current transformation.
* Copyright (C) 1993 Corona Design, Inc. All rights reserved.
*
* Abstract
* Encapsulates the interface for specifying viewing angle. This is
* done via CircularSliders specifying Latitude and Longitude.
*
* RCS path:
* $Source: /Users/pkron/Projects/voxel/Pyramid/RCS/TransformController.m,v $
* Modified: $Date: 93/09/15 12:35:26 $ by $Author: pkron $
* Current State: $State: Exp $ locked by $Locker: $
*/
#import "TransformController.h"
#import "standard.h"
// add some trigononmetry to standard Controls
@implementation Control( radians)
#define PI 3.1415926536
#define RAD(degrees) ((degrees)/180.*PI)
- (float)radiansValue
{
return( RAD( [self floatValue]));
}
- (float)cosValue
{
return( cos( [self radiansValue]));
}
- (float)sinValue
{
return( sin( [self radiansValue]));
}
@end
@implementation TransformController
- init
{
[super init];
transform = allocIdentity();
return( self);
}
#define DISTANCE ([distance floatValue]+1)
- (MATRIX)transform
{
POINT aPoint;
POINT up;
float cosLatitude = [latitude cosValue];
// compute normal from latitude/longitude
// vector has length 1 and is normal to
// viewing plane
aPoint[2] = [latitude sinValue];
aPoint[0] = cosLatitude * [longitude cosValue];
aPoint[1] = cosLatitude * [longitude sinValue];
aPoint[3] = 0;
// define UP. Note it must change as the
// viewing angle gets upside-down
up[0] = 0;
up[1] = 0;
up[2] = cosLatitude GE 0 ? 1 : -1;
up[3] = 0;
// create a new matrix with this setting
freeMatrix( transform);
transform = allocIdentity();
orient( transform, &aPoint, &up);
viewDistance( transform, DISTANCE);
return( transform);
}
@end
#ifdef _LOG
/*
* $Log: TransformController.m,v $
Revision 1.1 93/09/15 12:35:26 pkron
Created.
*/
#endif